home *** CD-ROM | disk | FTP | other *** search
- package org.apache.xalan.xslt;
-
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Stack;
- import java.util.StringTokenizer;
- import java.util.Vector;
- import org.apache.xalan.xpath.XPath;
- import org.apache.xalan.xpath.xml.MutableAttrListImpl;
- import org.apache.xalan.xpath.xml.NameSpace;
- import org.apache.xalan.xpath.xml.StringToStringTable;
- import org.apache.xalan.xpath.xml.XSLMessages;
- import org.w3c.dom.Node;
- import org.xml.sax.AttributeList;
- import org.xml.sax.DocumentHandler;
- import org.xml.sax.Locator;
- import org.xml.sax.SAXException;
-
- public class StylesheetHandler implements DocumentHandler {
- XSLTEngineImpl m_processor;
- Stylesheet m_stylesheet;
- Stack m_elems = new Stack();
- Stack m_whiteSpaceElems = new Stack();
- ElemTemplate m_template;
- ElemTemplateElement m_lastPopped;
- boolean m_inTemplate = false;
- boolean m_foundStylesheet = false;
- boolean m_foundNotImport = false;
- boolean m_inLXSLTScript = false;
- StringBuffer m_LXSLTScriptBody;
- String m_LXSLTScriptLang;
- String m_LXSLTScriptSrcURL;
- ExtensionNSHandler m_LXSLTExtensionNSH;
- public String m_includeBase;
- private boolean warnedAboutOldXSLTNamespace = false;
- static final String m_oldXSLNameSpaceURL = "http://www.w3.org/XSL/Transform/1.0";
-
- public StylesheetHandler(XSLTEngineImpl var1, Stylesheet var2) {
- this.m_processor = var1;
- this.m_stylesheet = var2;
- this.m_includeBase = this.m_stylesheet.m_baseIdent;
- }
-
- public void setDocumentLocator(Locator var1) {
- this.m_processor.m_stylesheetLocatorStack.push(var1);
- }
-
- public void startDocument() throws SAXException {
- }
-
- public void endDocument() throws SAXException {
- if (!this.m_processor.m_stylesheetLocatorStack.empty()) {
- this.m_processor.m_stylesheetLocatorStack.pop();
- }
-
- }
-
- private boolean isAttrOK(String var1, AttributeList var2, int var3) {
- return this.m_stylesheet.isAttrOK(var1, var2, var3);
- }
-
- private boolean processSpaceAttr(String var1, AttributeList var2, int var3) throws SAXException {
- boolean var4 = var1.equals("xml:space");
- if (var4) {
- String var5 = var2.getValue(var3);
- if (var5.equals("default")) {
- this.m_stylesheet.m_defaultSpace = true;
- } else {
- if (!var5.equals("preserve")) {
- throw new SAXException(XSLMessages.createMessage(77, new Object[]{var5}));
- }
-
- this.m_stylesheet.m_defaultSpace = false;
- }
- }
-
- return var4;
- }
-
- private boolean isXSLTNameSpace(String var1) throws SAXException {
- boolean var2 = false;
- boolean var3 = var1 != null && (var1.equals("http://www.w3.org/1999/XSL/Transform") || (var2 = var1.equals("http://www.w3.org/XSL/Transform/1.0")));
- if (var2 && !this.warnedAboutOldXSLTNamespace) {
- this.warnedAboutOldXSLTNamespace = true;
- this.m_processor.warn(18, new Object[]{var1});
- }
-
- return var3;
- }
-
- private String getLocalName(String var1) {
- int var2 = var1.indexOf(58);
- return var2 < 0 ? var1 : var1.substring(var2 + 1);
- }
-
- private void processStripAndPreserve(String var1, AttributeList var2, int var3, int var4, int var5) throws SAXException {
- ElemEmpty var6 = new ElemEmpty(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- int var7 = var2.getLength();
- boolean var8 = false;
-
- for(int var9 = 0; var9 < var7; ++var9) {
- String var10 = var2.getName(var9);
- if (var10.equals("elements")) {
- var8 = true;
- StringTokenizer var11 = new StringTokenizer(var2.getValue(var9), " \t\n\r");
-
- while(var11.hasMoreTokens()) {
- String var12 = var11.nextToken();
- XPath var13 = this.m_stylesheet.createMatchPattern(var12, var6);
- if (var3 == 33) {
- if (this.m_stylesheet.m_stylesheetRoot.m_whitespacePreservingElements == null) {
- this.m_stylesheet.m_stylesheetRoot.m_whitespacePreservingElements = new Vector();
- }
-
- this.m_stylesheet.m_stylesheetRoot.m_whitespacePreservingElements.addElement(var13);
- } else {
- if (this.m_stylesheet.m_stylesheetRoot.m_whitespaceStrippingElements == null) {
- this.m_stylesheet.m_stylesheetRoot.m_whitespaceStrippingElements = new Vector();
- }
-
- this.m_stylesheet.m_stylesheetRoot.m_whitespaceStrippingElements.addElement(var13);
- }
- }
- } else if (!this.isAttrOK(var10, var2, var9)) {
- this.m_stylesheet.error(2, new Object[]{var1, var10});
- }
- }
-
- if (!var8) {
- throw new SAXException(XSLMessages.createMessage(33, new Object[]{var1, "elements"}));
- }
- }
-
- public void startElement(String var1, AttributeList var2) throws SAXException {
- this.m_whiteSpaceElems.removeAllElements();
- Locator var3 = this.m_processor.m_stylesheetLocatorStack.isEmpty() ? null : (Locator)this.m_processor.m_stylesheetLocatorStack.peek();
- int var4 = var3 != null ? var3.getLineNumber() : 0;
- int var5 = var3 != null ? var3.getColumnNumber() : 0;
- this.m_stylesheet.pushNamespaces(var2);
- String var6 = this.m_stylesheet.getNamespaceFromStack(var1);
- String var7 = this.getLocalName(var1);
- Object var8 = null;
- int var9 = this.m_elems.size();
- if (var6 == null && var1.indexOf(":") > 0) {
- this.m_processor.warn(22, new Object[]{var1});
- } else if (!this.isXSLTNameSpace(var6)) {
- if (!this.m_inTemplate && var6 != null && (var6.equals("http://xml.apache.org/xslt") || var6.equals("http://xsl.lotus.com/") || var6.equals("http://xsl.lotus.com"))) {
- if (var7.equals("component")) {
- String var27 = null;
- String var32 = null;
- String var41 = null;
- int var48 = var2.getLength();
-
- for(int var52 = 0; var52 < var48; ++var52) {
- String var56 = var2.getName(var52);
- if (var56.equals("prefix")) {
- var27 = var2.getValue(var52);
- } else if (var56.equals("elements")) {
- var32 = var2.getValue(var52);
- } else if (var56.equals("functions")) {
- var41 = var2.getValue(var52);
- } else if (!this.isAttrOK(var56, var2, var52)) {
- this.m_stylesheet.error(2, new Object[]{var1, var56});
- }
- }
-
- if (var27 == null) {
- throw new SAXException(XSLMessages.createMessage(34, new Object[]{var1}));
- }
-
- String var57 = this.m_stylesheet.getNamespaceForPrefixFromStack(var27);
- if (var57 == null) {
- var57 = "";
- }
-
- ExtensionNSHandler var61 = this.m_stylesheet.lookupExtensionNSHandler(var57);
- if (var61 == null) {
- if (var57 == null) {
- var57 = "";
- }
-
- var61 = new ExtensionNSHandler(this.m_processor, var57);
- this.m_stylesheet.addExtensionNamespace(var57, var61);
- }
-
- var61.setScript("javaclass", var57, (String)null);
- if (var32 != null) {
- var61.setElements(var32);
- }
-
- if (var41 != null) {
- var61.setFunctions(var41);
- }
-
- this.m_LXSLTExtensionNSH = var61;
- } else if (var7.equals("script")) {
- this.m_inLXSLTScript = true;
- this.m_LXSLTScriptBody = new StringBuffer();
- int var28 = var2.getLength();
-
- for(int var33 = 0; var33 < var28; ++var33) {
- String var42 = var2.getName(var33);
- if (var42.equals("lang")) {
- this.m_LXSLTScriptLang = var2.getValue(var33);
- } else if (var42.equals("src")) {
- this.m_LXSLTScriptSrcURL = var2.getValue(var33);
- } else if (!this.isAttrOK(var42, var2, var33)) {
- this.m_stylesheet.error(2, new Object[]{var1, var42});
- }
- }
- }
- } else if (!this.m_inTemplate && !this.m_foundStylesheet) {
- int var26 = var2.getLength();
- boolean var31 = false;
-
- for(int var40 = 0; var40 < var26; ++var40) {
- String var47 = var2.getName(var40);
- String var51 = this.m_stylesheet.getNamespaceFromStack(var47);
- if (this.isXSLTNameSpace(var51)) {
- String var55 = this.getLocalName(var47);
- if (var55.equals("version")) {
- String var60 = var2.getValue(var40);
- this.m_stylesheet.m_XSLTVerDeclared = Double.valueOf(var60);
- var31 = true;
- }
- }
- }
-
- if (!var31) {
- this.m_processor.warn(23, (Object[])null);
- }
-
- var8 = this.initWrapperless(var1, var2, var4, var5);
- } else {
- ExtensionNSHandler var25 = null;
- String var30 = null;
- if (var6 != null) {
- int var39 = var2.getLength();
-
- for(int var46 = 0; var46 < var39; ++var46) {
- String var49 = var2.getName(var46);
- int var53 = var49.indexOf(58);
- if (var53 > 0) {
- String var58 = var49.substring(0, var53);
- if (!var58.equals("xmlns")) {
- String var62 = this.m_stylesheet.getNamespaceForPrefixFromStack(var58);
- if (var62 != null && var62.equals(this.m_stylesheet.m_XSLNameSpaceURL)) {
- String var69 = var49.substring(var53 + 1);
- if (var69.equals("extension-element-prefixes")) {
- String var71 = var2.getValue(var46);
- StringTokenizer var73 = new StringTokenizer(var71, " \t\n\r", false);
-
- for(int var75 = 0; var73.hasMoreTokens(); ++var75) {
- String var22 = var73.nextToken();
- String var23 = this.m_stylesheet.getNamespaceForPrefixFromStack(var22);
- if (var6 != null && var6.equals(var23)) {
- var25 = new ExtensionNSHandler(this.m_processor, var23);
- var30 = var23;
- break;
- }
- }
- }
- }
- }
- }
- }
-
- if (var25 == null) {
- for(ElemTemplateElement var50 = (ElemTemplateElement)this.m_elems.peek(); var50 != null; var50 = var50.m_parentNode) {
- int var54 = var50.getXSLToken();
- String[] var59 = null;
- if (var54 == 79) {
- ElemExtensionCall var63 = (ElemExtensionCall)var50;
- var59 = var63.m_extensionElementPrefixes;
- } else if (var54 == 77) {
- ElemLiteralResult var64 = (ElemLiteralResult)var50;
- var59 = var64.m_extensionElementPrefixes;
- }
-
- if (var59 != null) {
- for(String var72 : var59) {
- String var74 = this.m_stylesheet.getNamespaceForPrefixFromStack(var72);
- if (var6 != null && var6.equals(var74)) {
- var25 = new ExtensionNSHandler(this.m_processor, var74);
- var30 = var74;
- break;
- }
- }
- }
- }
- }
- }
-
- if (var6 != null && var25 == null) {
- var25 = this.m_stylesheet.lookupExtensionNSHandler(var6);
- var30 = var6;
- }
-
- if (var25 != null) {
- if (var30 == null) {
- var30 = "";
- }
-
- var8 = new ElemExtensionCall(this.m_processor, this.m_stylesheet, var30, var25.scriptLang, var25.scriptSrcURL, var25.scriptSrc, var1, var7, var2, var4, var5);
- } else {
- var8 = new ElemLiteralResult(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- }
- }
- } else {
- if (this.m_stylesheet.m_XSLNameSpaceURL != null) {
- this.m_stylesheet.m_XSLNameSpaceURL = var6;
- }
-
- if (!this.m_foundStylesheet) {
- this.m_stylesheet.initXSLTKeys();
- this.m_stylesheet.m_stylesheetRoot.initDefaultRule();
- this.m_stylesheet.getTemplateList().setIsWrapperless(false);
- }
-
- Object var10 = Stylesheet.m_elementKeys.get(var7);
- int var11 = var10 != null ? (Integer)var10 : -2;
- if (this.m_inTemplate) {
- switch (var11) {
- case 2:
- var8 = new ElemWithParam(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 9:
- var8 = new ElemCopy(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 11:
- case 19:
- case 26:
- case 27:
- case 31:
- case 32:
- case 33:
- case 40:
- case 54:
- case 63:
- case 76:
- throw new SAXException(XSLMessages.createMessage(73, new Object[]{var1}));
- case 17:
- var8 = new ElemCallTemplate(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 28:
- var8 = new ElemForEach(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 30:
- var8 = new ElemValueOf(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 34:
- var8 = new ElemUse(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 35:
- var8 = new ElemNumber(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 36:
- var8 = new ElemIf(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 37:
- var8 = new ElemChoose(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 38:
- ElemTemplateElement var38 = (ElemTemplateElement)this.m_elems.peek();
- if (var38.getXSLToken() != 37) {
- throw new SAXException(XSLMessages.createMessage(70, (Object[])null));
- }
-
- ElemTemplateElement var45 = (ElemTemplateElement)var38.getLastChild();
- if (var45 != null && var45.getXSLToken() != 38) {
- throw new SAXException(XSLMessages.createMessage(69, (Object[])null));
- }
-
- var8 = new ElemWhen(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 39:
- ElemTemplateElement var37 = (ElemTemplateElement)this.m_elems.peek();
- if (var37.getXSLToken() != 37) {
- throw new SAXException(XSLMessages.createMessage(72, (Object[])null));
- }
-
- ElemTemplateElement var44 = (ElemTemplateElement)var37.getLastChild();
- if (var44 != null && var44.getXSLToken() != 38) {
- throw new SAXException(XSLMessages.createMessage(71, (Object[])null));
- }
-
- var8 = new ElemOtherwise(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 41:
- var8 = new ElemParam(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 42:
- this.m_elems.push(new ElemText(this.m_processor, this.m_stylesheet, var1, var2, var4, var5));
- break;
- case 46:
- var8 = new ElemElement(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 48:
- var8 = new ElemAttribute(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 50:
- var8 = new ElemApplyTemplates(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 57:
- var8 = new ElemFallback(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 58:
- var8 = new ElemPI(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 59:
- var8 = new ElemComment(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 64:
- try {
- ElemForEach var36 = (ElemForEach)this.m_elems.peek();
- ElemSort var43 = new ElemSort(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- if (var36.m_sortElems == null) {
- var36.m_sortElems = new Vector();
- }
-
- var36.m_sortElems.addElement(var43);
- var43.m_parentNode = var36;
- break;
- } catch (ClassCastException var24) {
- throw new SAXException(XSLMessages.createMessage(68, (Object[])null));
- }
- case 72:
- var8 = new ElemApplyImport(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 73:
- var8 = new ElemVariable(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 74:
- var8 = new ElemCopyOf(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 75:
- var8 = new ElemMessage(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- case 83:
- var8 = new ElemDecimalFormat(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- break;
- default:
- if (this.m_stylesheet.m_XSLTVerDeclared <= (double)1.0F) {
- throw new SAXException(XSLMessages.createMessage(67, new Object[]{var7}));
- }
- }
- } else {
- if (this.m_foundStylesheet && var11 != 26) {
- this.m_foundNotImport = true;
- }
-
- switch (var11) {
- case 2:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 12:
- case 15:
- case 16:
- case 17:
- case 28:
- case 30:
- case 34:
- case 35:
- case 36:
- case 37:
- case 38:
- case 39:
- case 42:
- case 46:
- case 48:
- case 50:
- case 58:
- case 59:
- case 64:
- case 66:
- case 67:
- case 68:
- case 69:
- case 71:
- case 72:
- case 74:
- case 75:
- throw new SAXException(XSLMessages.createMessage(62, new Object[]{var1}));
- case 19:
- this.m_template = new ElemTemplate(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- this.m_elems.push(this.m_template);
- this.m_inTemplate = true;
- this.m_stylesheet.getTemplateList().addTemplate(this.m_template);
- break;
- case 25:
- this.m_stylesheet.getTemplateList().setIsWrapperless(false);
- this.m_foundStylesheet = true;
- int var14 = var2.getLength();
- boolean var15 = false;
- int var16 = 0;
-
- for(; var16 < var14; ++var16) {
- String var17 = var2.getName(var16);
- if (var17.equals("result-ns")) {
- throw new SAXException(XSLMessages.createMessage(63, (Object[])null));
- }
-
- if (var17.equals("default-space")) {
- throw new SAXException(XSLMessages.createMessage(64, (Object[])null));
- }
-
- if (var17.equals("exclude-result-prefixes")) {
- StringToStringTable var18 = this.m_stylesheet.getExcludeResultPrefixes();
- var18 = this.m_stylesheet.processExcludeResultPrefixes(var2.getValue(var16), var18);
- this.m_stylesheet.setExcludeResultPrefixes(var18);
- } else if (var17.equals("extension-element-prefixes")) {
- StringTokenizer var67 = new StringTokenizer(var2.getValue(var16), " \t\n\r", false);
-
- while(var67.hasMoreTokens()) {
- String var19 = var67.nextToken();
- String var20 = this.m_stylesheet.getNamespaceForPrefixFromStack(var19);
- if (var20 == null) {
- var20 = "";
- }
-
- ExtensionNSHandler var21 = new ExtensionNSHandler(this.m_processor, var20);
- this.m_stylesheet.addExtensionNamespace(var20, var21);
- }
- } else if (!var17.equals("id")) {
- if (var17.equals("indent-result")) {
- throw new SAXException(XSLMessages.createMessage(65, (Object[])null));
- }
-
- if (var17.equals("version")) {
- String var68 = var2.getValue(var16);
- this.m_stylesheet.m_XSLTVerDeclared = Double.valueOf(var68);
- var15 = true;
- } else if (!this.isAttrOK(var17, var2, var16) && !this.processSpaceAttr(var17, var2, var16) && !this.m_stylesheet.getTemplateList().getIsWrapperless()) {
- throw new SAXException(XSLMessages.createMessage(66, new Object[]{var1, var17}));
- }
- }
-
- if (!this.m_stylesheet.m_namespaces.empty()) {
- this.m_stylesheet.m_namespaceDecls = (NameSpace)this.m_stylesheet.m_namespaces.peek();
- }
- }
-
- if (!var15) {
- this.m_processor.warn(23, (Object[])null);
- }
- break;
- case 26:
- this.processImport(var1, var2);
- break;
- case 27:
- this.processInclude(var1, var2);
- break;
- case 31:
- ElemEmpty var35 = new ElemEmpty(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- this.m_stylesheet.processKeyElement(var35, var2);
- break;
- case 32:
- case 33:
- this.processStripAndPreserve(var1, var2, var11, var4, var5);
- break;
- case 40:
- this.m_inTemplate = true;
- ElemAttributeSet var34 = new ElemAttributeSet(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- this.m_elems.push(var34);
- break;
- case 41:
- case 73:
- Object var12 = var11 == 41 ? new ElemParam(this.m_processor, this.m_stylesheet, var1, var2, var4, var5) : new ElemVariable(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- this.m_elems.push(var12);
- this.m_inTemplate = true;
- this.m_stylesheet.setTopLevelVariable((ElemVariable)var12);
- ((ElemVariable)var12).m_isTopLevel = true;
- break;
- case 54:
- if (var6 != null && !var6.equals("http://xml.apache.org/xslt") && !var6.equals("http://xsl.lotus.com/") && !var6.equals("http://xsl.lotus.com")) {
- this.m_processor.warn(9, new Object[]{"http://xml.apache.org/xslt"});
- }
- break;
- case 65:
- this.m_processor.m_translateCSS = true;
- break;
- case 76:
- this.m_processor.warn(80);
- break;
- case 80:
- this.m_stylesheet.m_stylesheetRoot.processOutputSpec(var1, var2);
- break;
- case 83:
- ElemDecimalFormat var13 = new ElemDecimalFormat(this.m_processor, this.m_stylesheet, var1, var2, var4, var5);
- this.m_stylesheet.processDecimalFormatElement(var13, var2);
- break;
- case 84:
- this.m_stylesheet.processNSAliasElement(var1, var2);
- break;
- default:
- throw new SAXException(XSLMessages.createMessage(67, new Object[]{var7}));
- }
- }
- }
-
- if (this.m_inTemplate && var8 != null) {
- if (!this.m_elems.empty()) {
- ElemTemplateElement var29 = (ElemTemplateElement)this.m_elems.peek();
- var29.appendChild((Node)var8);
- }
-
- this.m_elems.push(var8);
- }
-
- if (var9 == this.m_elems.size()) {
- this.m_elems.push(new ElemEmpty(this.m_processor, this.m_stylesheet, var1, var2, var4, var5));
- }
-
- }
-
- private ElemTemplateElement initWrapperless(String var1, AttributeList var2, int var3, int var4) throws SAXException {
- this.m_stylesheet.initXSLTKeys();
- this.m_stylesheet.m_stylesheetRoot.initDefaultRule();
- MutableAttrListImpl var5 = new MutableAttrListImpl();
- var5.addAttribute("name", "CDATA", "simple");
- this.m_template = new ElemTemplate(this.m_processor, this.m_stylesheet, "xsl:template", var5, var3, var4);
- ElemLiteralResult var6 = new ElemLiteralResult(this.m_processor, this.m_stylesheet, var1, var2, var3, var4);
- this.m_template.appendChild(var6);
- this.m_inTemplate = true;
- this.m_stylesheet.getTemplateList().setWrapperlessTemplate(this.m_template);
- this.m_stylesheet.getTemplateList().setIsWrapperless(true);
- this.m_foundStylesheet = true;
- if (var1.equals("HTML")) {
- this.m_stylesheet.m_stylesheetRoot.m_indentResult = true;
- this.m_stylesheet.m_stylesheetRoot.setOutputMethod("html");
- }
-
- return var6;
- }
-
- private void processImport(String var1, AttributeList var2) throws SAXException {
- int var3 = var2.getLength();
- boolean var4 = false;
-
- for(int var5 = 0; var5 < var3; ++var5) {
- String var6 = var2.getName(var5);
- if (var6.equals("href")) {
- var4 = true;
- if (this.m_foundNotImport) {
- throw new SAXException(XSLMessages.createMessage(75, (Object[])null));
- }
-
- String var7 = this.m_stylesheet.m_XSLNameSpaceURL;
- String var8 = var2.getValue(var5);
- URL var9 = this.m_processor.getURLFromString(var8, ((URL)this.m_stylesheet.m_includeStack.peek()).toString());
- if (this.stackContains(this.m_stylesheet.m_stylesheetRoot.m_importStack, var9)) {
- throw new SAXException(XSLMessages.createMessage(76, new Object[]{var9}));
- }
-
- this.m_stylesheet.m_stylesheetRoot.m_importStack.push(var9);
-
- try {
- Stylesheet var10 = new Stylesheet(this.m_stylesheet.m_stylesheetRoot, this.m_processor, var9.toExternalForm());
- StylesheetHandler var11 = new StylesheetHandler(this.m_processor, var10);
- var10.m_baseIdent = var9.toExternalForm();
- this.m_processor.parseXML(var9, var11, var10);
- this.m_stylesheet.m_imports.insertElementAt(var10, 0);
- var10.m_stylesheetParent = this.m_stylesheet;
- } catch (MalformedURLException var12) {
- throw new SAXException(XSLMessages.createMessage(35, new Object[]{var2.getValue(var5)}), var12);
- } catch (FileNotFoundException var13) {
- throw new SAXException(XSLMessages.createMessage(36, new Object[]{var2.getValue(var5)}), var13);
- } catch (IOException var14) {
- throw new SAXException(XSLMessages.createMessage(37, new Object[]{var2.getValue(var5)}), var14);
- }
-
- this.m_stylesheet.m_stylesheetRoot.m_importStack.pop();
- this.m_stylesheet.m_XSLNameSpaceURL = var7;
- } else if (!this.isAttrOK(var6, var2, var5)) {
- this.m_stylesheet.error(2, new Object[]{var1, var6});
- }
- }
-
- if (!var4) {
- throw new SAXException(XSLMessages.createMessage(38, new Object[]{var1}));
- }
- }
-
- private boolean stackContains(Stack var1, URL var2) {
- int var3 = ((Vector)var1).size();
- boolean var4 = false;
-
- for(int var5 = 0; var5 < var3; ++var5) {
- URL var6 = (URL)((Vector)var1).elementAt(var5);
- if (var6.toString().equals(var2.toString())) {
- var4 = true;
- break;
- }
- }
-
- return var4;
- }
-
- private void processInclude(String var1, AttributeList var2) throws SAXException {
- int var3 = var2.getLength();
- boolean var4 = false;
-
- for(int var5 = 0; var5 < var3; ++var5) {
- String var6 = var2.getName(var5);
- if (var6.equals("href")) {
- var4 = true;
- Stack var7 = this.m_elems;
- this.m_elems = new Stack();
- ElemTemplate var8 = this.m_template;
- this.m_template = null;
- ElemTemplateElement var9 = this.m_lastPopped;
- this.m_lastPopped = null;
- boolean var10 = this.m_inTemplate;
- this.m_inTemplate = false;
- boolean var11 = this.m_foundStylesheet;
- this.m_foundStylesheet = false;
- String var12 = this.m_stylesheet.m_XSLNameSpaceURL;
- boolean var13 = this.m_foundNotImport;
- this.m_foundNotImport = false;
- NameSpace var14 = this.m_stylesheet.m_namespaceDecls;
- this.m_stylesheet.m_namespaceDecls = null;
- Stack var15 = this.m_stylesheet.m_namespaces;
- this.m_stylesheet.m_namespaces = new Stack();
- String var16 = var2.getValue(var5);
- URL var17 = this.m_processor.getURLFromString(var16, ((URL)this.m_stylesheet.m_includeStack.peek()).toString());
- if (this.stackContains(this.m_stylesheet.m_includeStack, var17)) {
- throw new SAXException(XSLMessages.createMessage(76, new Object[]{var17}));
- }
-
- this.m_stylesheet.m_includeStack.push(var17);
-
- try {
- this.m_processor.parseXML(var17, this, this.m_stylesheet);
- } catch (IOException var19) {
- throw new SAXException(XSLMessages.createMessage(40, (Object[])null), var19);
- }
-
- this.m_stylesheet.m_includeStack.pop();
- this.m_elems = var7;
- this.m_template = var8;
- this.m_lastPopped = var9;
- this.m_inTemplate = var10;
- this.m_foundStylesheet = var11;
- this.m_stylesheet.m_XSLNameSpaceURL = var12;
- this.m_foundNotImport = var13;
- this.m_stylesheet.m_namespaceDecls = var14;
- this.m_stylesheet.m_namespaces = var15;
- } else if (!this.isAttrOK(var6, var2, var5)) {
- this.m_stylesheet.error(2, new Object[]{var1, var6});
- }
- }
-
- if (!var4) {
- throw new SAXException(XSLMessages.createMessage(38, new Object[]{var1}));
- }
- }
-
- public void endElement(String var1) throws SAXException {
- this.m_stylesheet.popNamespaces();
- this.m_lastPopped = (ElemTemplateElement)this.m_elems.pop();
- this.m_lastPopped.m_finishedConstruction = true;
- int var2 = this.m_lastPopped.getXSLToken();
- if (var2 == 19) {
- this.m_inTemplate = false;
- } else if (var2 != 41 && var2 != 73) {
- if (var2 == 40) {
- this.m_inTemplate = false;
- }
- } else {
- ElemVariable var3 = (ElemVariable)this.m_lastPopped;
- if (var3.m_isTopLevel) {
- this.m_inTemplate = false;
- }
- }
-
- if (this.m_inLXSLTScript) {
- if (this.m_LXSLTScriptLang == null) {
- throw new SAXException(XSLMessages.createMessage(41, new Object[]{var1}));
- } else if (this.m_LXSLTExtensionNSH == null) {
- throw new SAXException(XSLMessages.createMessage(42, new Object[]{var1}));
- } else {
- this.m_LXSLTExtensionNSH.setScript(this.m_LXSLTScriptLang, this.m_LXSLTScriptSrcURL, this.m_LXSLTScriptBody.toString());
- this.m_inLXSLTScript = false;
- this.m_LXSLTScriptLang = null;
- this.m_LXSLTScriptSrcURL = null;
- this.m_LXSLTScriptBody = null;
- this.m_LXSLTExtensionNSH = null;
- }
- } else {
- if (this.m_LXSLTExtensionNSH != null) {
- this.m_inLXSLTScript = false;
- this.m_LXSLTScriptLang = null;
- this.m_LXSLTScriptSrcURL = null;
- this.m_LXSLTScriptBody = null;
- this.m_LXSLTExtensionNSH = null;
- }
-
- }
- }
-
- public static boolean isSpace(char var0) {
- return var0 == ' ' || var0 == '\t' || var0 == '\r' || var0 == '\n';
- }
-
- public boolean isWhiteSpace(char[] var1, int var2, int var3) {
- boolean var4 = true;
- int var5 = var2 + var3;
-
- for(int var6 = var2; var6 < var5; ++var6) {
- if (!isSpace(var1[var6])) {
- var4 = false;
- break;
- }
- }
-
- return var4;
- }
-
- public void characters(char[] var1, int var2, int var3) throws SAXException {
- if (!this.m_inTemplate) {
- if (this.m_inLXSLTScript) {
- this.m_LXSLTScriptBody.append(var1, var2, var3);
- }
- } else {
- ElemTemplateElement var4 = (ElemTemplateElement)this.m_elems.peek();
- boolean var5 = false;
- boolean var6 = false;
- if (var4.getXSLToken() == 42) {
- var6 = ((ElemText)var4).m_disableOutputEscaping;
- var4 = (ElemTemplateElement)this.m_elems.elementAt(this.m_elems.size() - 2);
- var5 = true;
- }
-
- Locator var7 = this.m_processor.m_stylesheetLocatorStack.isEmpty() ? null : (Locator)this.m_processor.m_stylesheetLocatorStack.peek();
- int var8 = var7 != null ? var7.getLineNumber() : 0;
- int var9 = var7 != null ? var7.getColumnNumber() : 0;
- ElemTextLiteral var10 = new ElemTextLiteral(this.m_processor, this.m_stylesheet, var1, var2, var3, false, var5, var6, var8, var9);
- boolean var11 = this.isWhiteSpace(var1, var2, var3);
- if (var5 || !var5 && !var11) {
- while(!this.m_whiteSpaceElems.isEmpty()) {
- ElemTextLiteral var17 = (ElemTextLiteral)this.m_whiteSpaceElems.pop();
- var4.appendChild(var17);
- }
-
- var4.appendChild(var10);
- return;
- }
-
- if (var11) {
- boolean var12 = true;
- Node var13 = var4.getLastChild();
- if (var13 != null) {
- ElemTemplateElement var14 = (ElemTemplateElement)var13;
- boolean var15 = var14.getXSLToken() == 78;
- boolean var16 = this.m_lastPopped != null && this.m_lastPopped.getXSLToken() == 42;
- if (var15 && !var16) {
- var4.appendChild(var10);
- var12 = false;
- }
- }
-
- if (var12) {
- this.m_whiteSpaceElems.push(var10);
- return;
- }
- }
- }
-
- }
-
- public void cdata(char[] var1, int var2, int var3) throws SAXException {
- if (this.m_inTemplate) {
- ElemTemplateElement var4 = (ElemTemplateElement)this.m_elems.peek();
- boolean var5 = false;
- boolean var6 = false;
- if (var4.getXSLToken() == 42) {
- var6 = ((ElemText)var4).m_disableOutputEscaping;
- var4 = (ElemTemplateElement)this.m_elems.elementAt(this.m_elems.size() - 2);
- var5 = true;
- }
-
- Locator var7 = this.m_processor.m_stylesheetLocatorStack.isEmpty() ? null : (Locator)this.m_processor.m_stylesheetLocatorStack.peek();
- int var8 = var7 != null ? var7.getLineNumber() : 0;
- int var9 = var7 != null ? var7.getColumnNumber() : 0;
- ElemTextLiteral var10 = new ElemTextLiteral(this.m_processor, this.m_stylesheet, var1, var2, var3, true, var5, var6, var8, var9);
- boolean var11 = this.isWhiteSpace(var1, var2, var3);
- if (var5 || !var5 && !var11) {
- while(!this.m_whiteSpaceElems.isEmpty()) {
- ElemTextLiteral var17 = (ElemTextLiteral)this.m_whiteSpaceElems.pop();
- var4.appendChild(var17);
- }
-
- var4.appendChild(var10);
- } else if (var11) {
- boolean var12 = true;
- Node var13 = var4.getLastChild();
- if (var13 != null) {
- ElemTemplateElement var14 = (ElemTemplateElement)var13;
- boolean var15 = var14.getXSLToken() == 78;
- boolean var16 = this.m_lastPopped != null && this.m_lastPopped.getXSLToken() == 42;
- if (var15 && !var16) {
- var4.appendChild(var10);
- var12 = false;
- }
- }
-
- if (var12) {
- this.m_whiteSpaceElems.push(var10);
- }
- }
- } else if (this.m_inLXSLTScript) {
- this.m_LXSLTScriptBody.append(var1, var2, var3);
- }
-
- this.m_lastPopped = null;
- }
-
- public void ignorableWhitespace(char[] var1, int var2, int var3) throws SAXException {
- this.m_lastPopped = null;
- }
-
- public void processingInstruction(String var1, String var2) throws SAXException {
- }
-
- public void comment(String var1) throws SAXException {
- }
-
- public void entityReference(String var1) throws SAXException {
- }
- }
-